package com.cy.pj.Goods.dao;

import com.cy.pj.Goods.pojo.Gooods;
import org.apache.ibatis.session.SqlSession;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public class GoodsDaoImpl implements GooodsDao {
    @Autowired
    private SqlSession session;
    private final Logger log = LoggerFactory.getLogger(GooodsDao.class);

    @Override
    public List<Gooods> getGoods() {
        List<Gooods> list = null;
        try {
            System.out.println("getGoods()");
            String stat = "com.cy.pj.Goods.dao.GooodsDao.getGood";
            list = session.selectList(stat);
        } catch (Exception e) {
            log.error("getGoods is + {}", e.getMessage());
        } finally {
            return list;
        }
    }

    @Override
    public Gooods getGoodsOne(int id) {
        System.out.println("getGoodsOne");
        String stat = "com.cy.pj.Goods.pojo.Gooods";
        Gooods gooods = session.selectOne(stat, id);
        return gooods;
    }

    @Override
    public int deleteGoods(int id) {
        return 0;
    }


}
